package com.ocom.mjrecode.controller;

import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.ocom.common.entity.mjrecode.MjAttendance;
import com.ocom.common.resp.Result;
import com.ocom.common.utils.ResultUtil;
import com.ocom.mjrecode.service.MjAttendanceService;
import com.ocom.redis.util.RedisUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description: TODO
 * @Author: ouqing
 * @Date: 2025/10/8
 **/
@RestController
public class MjAttendanceController {

  private Logger logger = LoggerFactory.getLogger(MjLogController.class);

  @Autowired
  private MjAttendanceService mjAttendanceService;

//  @Autowired
//  private AccessClientService accessClientService;

  @Resource
  private RedisUtil redisUtil;

  // 一个临时插入单条数据的接口
  @PostMapping("/mjattendance")
  public Result initInsert(@RequestBody MjAttendance mjAttendance){
    mjAttendanceService.initInsert(mjAttendance);
    return ResultUtil.success();
  }

  // 单条记录修改
  @PutMapping("/mjattendance/{id}")
  public Result initUpdate(@PathVariable Long id,@RequestBody MjAttendance mjAttendance){
    mjAttendanceService.initUpdateById(id, mjAttendance);
    return ResultUtil.success();
  }

  // 批量插入
  @PostMapping("/mjattendance/initBatch")
  public Result initBatchInsert(@RequestBody List<MjAttendance> list){
    if (!CollectionUtils.isEmpty(list)){
      mjAttendanceService.initBatchInsert(list);
    }
    return ResultUtil.success();
  }

  // 批量修改
  @PostMapping("/mjattendance/initUpdateBatch")
  public Result initBatchUpdate(@RequestBody List<MjAttendance> list){
    if (!CollectionUtils.isEmpty(list)){
      mjAttendanceService.initBatchUpdate(list);
    }
    return ResultUtil.success();
  }










}
